
********************************************************************************
********************************************************************************
********************************************************************************

set more off 

cd "/home/nomero/Scrivania/MediaSOEFOE/Old/data"

****

use "merged_2018_final.dta",clear

append using "merged_2019_final.dta"

**** TURNOUT + INDEC

recode VOTO18 (1/94=1 "Voto") (95 96 99=2 "Non voto") (98=3 "Indec"),gen(TOUT_P_18)
recode VOTO19 (1/9=1 "Voto") (11/99=2 "Non voto") (10=3 "Indec"),gen(TOUT_P_19)

gen TURNOUT_P = TOUT_P_18
replace TURNOUT_P = TOUT_P_19 if TOUT_P_18 ==.

**** LEVEL 2

gen wave100 = wave *100
gen expos = wave100 + OUTLET

**** NEGAT

replace NEGAT = NEGAT*100

**** ELECTION

recode YEAR (2018=1 "2018") (2019=2 "2019"),gen(ELECTION)

**** INFO SOURCE

recode OUTLET (1 2 3 4 5=1 "Press") (11 12 13 14 15=2 "TV"),gen(INFO_SOURCE)

**** DISAFFECTION

recode POL_DISAFFECTION (0/0.5=1) (0.6/1=0),gen(DISAFF)

********************************************************************************
********************************************************************************
********************************************************************************
**** ANALYSIS

recode TURNOUT_P (3=0 "Indeciso") (2=1 "Non-voto")  (1=2 "Voto"),gen(TURNOUT_P3)
rename TURNOUT_P TURNOUT_P2 
rename TURNOUT_P3 TURNOUT_P 

*****
***** TABLE 1 - MODEL 1
*****

mlogit TURNOUT_P i.EDUC i.LRSP i.GENDER c.AGE i.DISAFF c.NEGAT i.ELECTION i.INFO_SOURCE i.wave,base(0)
*outreg2 using "Tab1",excel dec(2) side

estimates store negat

quietly margins, at(NEGAT=(5(1)45)) predict(outcome(0)) post
estimates store undec
estimates restore negat

quietly margins, at(NEGAT=(5(1)45)) predict(outcome(1)) post
estimates store nonv
estimates restore negat

quietly margins, at(NEGAT=(5(1)45)) predict(outcome(2)) post
estimates store voters 

*****
***** FIGURE 1
*****

coefplot voters nonv undec,vert scheme(plotplain) recast(line) ///
 xlab(0 "0" 10 "10" 20 "20" 30 "30" 40 "40" 45 " ")

*****
***** TABLE 1 - MODEL 2
*****

mlogit TURNOUT_P i.EDUC i.LRSP i.GENDER c.AGE i.DISAFF i.ELECTION##c.NEGAT i.INFO_SOURCE i.wave,base(0)
*outreg2 using "Tab1",excel dec(2) side

quietly margins, dydx(NEGAT) at(ELECTION=(1 2)) predict(outcome(0)) post
estimates store undec
estimates restore negat

quietly margins, dydx(NEGAT) at(ELECTION=(1 2)) predict(outcome(1)) post
estimates store nonv
estimates restore negat

quietly margins, dydx(NEGAT) at(ELECTION=(1 2)) predict(outcome(2)) post
estimates store voters 

*****
***** FIGURE 2
*****

coefplot voters nonv undec, scheme(plotplain) xline(0)  ylab(1 "FOE" 2 "SOE")

*****
***** ADDITIONAL TEST
*****

mlogit TURNOUT_P i.EDUC i.LRSP i.GENDER c.AGE i.DISAFF i.ELECTION##c.NEGAT i.INFO_SOURCE i.wave,base(1)

margins, dydx(NEGAT) at(ELECTION=(1 2)) predict(outcome(2)) post

test [1._at]  = [2._at]
